<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'account.label', default: 'Account')}"/>
    <title>客户详情</title>
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>客户详情</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="account" action="index">客户列表</g:link>
                    </li>
                    <li class="breadcrumb-item">客户详情</li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message alert alert-info" role="status">${flash.message}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span></button>
                </div>
            </g:if>

        <!-- Hover table card start -->
        <div class="card">
                <div class="card-header">
                    <h5>客户详情</h5>

                    <div class="card-header-right">
                        <g:link action="edit" resource="${this.account}" data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑">
                            <i class="icofont icofont-edit"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">名称</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.name}</div>
                        </div>
                        <label class="col-md-2 col-form-label">曾用名</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.alias}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">类型</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.type?.name}</div>
                        </div>
                        <label class="col-md-2 col-form-label">分级</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.level?.name}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">行业</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.industry}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">雇员数量</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.numberOfEmployees}</div>
                        </div>
                        <label class="col-md-2 col-form-label">网站</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.website}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">国家</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.country}</div>
                        </div>

                        <label class="col-md-2 col-form-label">城市</label>
                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.city}</div>
                        </div>
                    </div>  

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">注册资本货币类型</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.currencyType}</div>
                        </div>

                        <label class="col-md-2 col-form-label">
                            <g:if test="${this.account?.registeredCapital < 10000}">
                                注册资本（元）
                            </g:if>
                            <g:if test="${10000 <= this.account?.registeredCapital && this.account?.registeredCapital < 1000000}">
                                注册资本（万元）
                            </g:if>
                            <g:if test="${1000000 <= this.account?.registeredCapital && this.account?.registeredCapital < 10000000}">
                                注册资本（百万）
                            </g:if>
                            <g:if test="${10000000 <= this.account?.registeredCapital && this.account?.registeredCapital < 100000000}">
                                注册资本（千万）
                            </g:if>
                            <g:if test="${this.account?.registeredCapital >= 100000000}">
                                注册资本（亿）
                            </g:if>

                        </label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                                <g:if test="${this.account?.registeredCapital <10000}">
                                    <g:formatNumber number="${this.account?.registeredCapital}"
                                                    type="number" maxFractionDigits="2"
                                                    minFractionDigits="2"/>
                                </g:if>
                                <g:if test="${10000 <= this.account?.registeredCapital && this.account?.registeredCapital < 1000000}">
                                    <g:formatNumber number="${this.account?.registeredCapital/10000}"
                                                    type="number" maxFractionDigits="2"
                                                    minFractionDigits="2"/>
                                </g:if>
                                <g:if test="${1000000 <= this.account?.registeredCapital && this.account?.registeredCapital < 10000000}">
                                    <g:formatNumber number="${this.account?.registeredCapital/1000000}"
                                                    type="number" maxFractionDigits="2"
                                                    minFractionDigits="2"/>
                                </g:if>
                                <g:if test="${10000000 <= this.account?.registeredCapital && this.account?.registeredCapital < 100000000}">
                                    <g:formatNumber number="${this.account?.registeredCapital/10000000}"
                                                    type="number" maxFractionDigits="2"
                                                    minFractionDigits="2"/>
                                </g:if>
                                <g:if test="${this.account?.registeredCapital >= 100000000}">
                                    <g:formatNumber number="${this.account?.registeredCapital/100000000}"
                                                    type="number" maxFractionDigits="2"
                                                    minFractionDigits="2"/>
                                </g:if>
                            </div>
                        </div>
                    </div>            

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">上级客户</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.parent}</div>
                        </div>

                    </div>

                     <div class="form-group row">                        
                        <label class="col-md-2 col-form-label">启用</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.active}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">所处行业</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.territory?.name}</div>
                        </div>
                        <label class="col-md-2 col-form-label">所有者</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.user?.fullName}</div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">创建时间</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                                <g:formatDate date="${this.account?.createdDate}"
                                              format="yyyy-MM-dd HH:mm:ss"></g:formatDate>
                            </div>
                        </div>
                        <label class="col-md-2 col-form-label">修改时间</label>

                        <div class="col-md-3">
                            <div class="form-control-static">
                                <g:formatDate date="${this.account?.modifiedDate}"
                                              format="yyyy-MM-dd HH:mm:ss"></g:formatDate>
                            </div>
                        </div>
                    </div>

                    <div class="form-group row">
                        <label class="col-md-2 col-form-label">描述</label>

                        <div class="col-md-3">
                            <div class="form-control-static">${this.account?.description}</div>
                        </div>
                    </div>

                </div>

            </div>
            <!-- Hover table card end -->
            <div class="card">
                <div class="card-header">
                    <h5>定制字段</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/flexFieldInstanceTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>详细地址</h5>

                    <div class="card-header-right">
                        <g:link controller="address" action="create" params="[account: this.account?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/addressTemplate"/>
            </div>

            <div class="card">
               <div class="card-header">
                   <h5>笔记</h5>

                   <div class="card-header-right">
                       <g:link controller="note" action="create" params="[account: this.account?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                           <i class="icofont icofont-plus"></i>
                       </g:link>
                       <i class="icofont icofont-rounded-down"></i>
                   </div>
               </div>
               <g:render template="/layouts/mashTemplate/noteTemplate"/>
           </div>

           <div class="card">
                <div class="card-header">
                    <h5>联系人</h5>

                    <div class="card-header-right">
                        <g:link controller="contact" action="create" params="[account: this.account?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <div class="card-block dt-responsive">

                    <div class="table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="contact" title="姓名"/>
                                    <g:sortableColumn property="cellphone" title="手机"/>
                                    <g:sortableColumn property="email" title="邮箱"/>
                                    <g:sortableColumn property="country" title="国家"/>
                                    <g:sortableColumn property="city" title="城市"/>
                                    <g:sortableColumn property="active" width="8%" title="操作"/>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${com.next.Contact.findAllByAccount(this.account)}">
                                    <tr>
                                        <td>
                                          <g:link action="show" controller="contact" id="${it?.id}"
                                                    class="firstTd">${it?.fullName}</g:link>
                                        </td>
                                        <td>${it?.cellphone}</td>
                                        <td>${it?.email}</td>
                                        <td>${it?.country?.name}</td>
                                        <td>${it?.city?.name}</td>

                                        <td class="text-center">
                                            <g:link class="m-r-15 text-primary"
                                                    controller="contact" action="edit"
                                                    id="${it?.id}">
                                                <i class="icofont icofont-ui-edit"></i>
                                            </g:link>

                                            <g:form resource="${it}" class="inline" method="DELETE">
                                                <button class="deleteBtn text-danger" type="button">
                                                    <i class="icofont icofont-trash"></i>
                                                </button>
                                            </g:form>
                                        </td>
                                    </tr>
                                </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>拜访</h5>

                    <div class="card-header-right">
                        <g:link controller="activity" action="createAppointment" params="[account: this.account?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/appointmentTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>任务</h5>

                    <div class="card-header-right">
                        <g:link controller="activity" action="createTask" params="[account: this.account?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/taskTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>文档</h5>

                    <div class="card-header-right">
                        <g:link controller="attachment" action="create" params="[account: this.account?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/attachmentTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>团队</h5>

                    <div class="card-header-right">
                        <g:link controller="accountTeam" action="create" params="[account: this.account?.id]" data-toggle="tooltip" data-placement="top" title="" data-original-title="新增">
                            <i class="icofont icofont-plus"></i>
                        </g:link>
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/teamTemplate"/>
            </div>

            <div class="card">
                <div class="card-header">
                    <h5>商机</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>
                <g:render template="/layouts/mashTemplate/opportunityListTemplate"/>
            </div>


          </div>
          <!-- Page-body end -->

        </div>
</div>

</body>

</html>
